package com.woniu.order.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.injector.methods.Insert;
import com.woniu.order.infra.model.OrderFlowing;
import com.woniu.order.infra.mapper.OrderFlowingMapper;
import com.woniu.order.service.OrderFlowingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.order.service.dto.OrderFlowingDto;
import com.woniu.order.service.param.AddOrderFlowingServiceParam;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 支付流水记录表 服务实现类
 * </p>
 *
 * @author Lucas
 * @since 2022-11-26
 */
@Service
public class OrderFlowingServiceImpl extends ServiceImpl<OrderFlowingMapper, OrderFlowing> implements OrderFlowingService {

    /**
     * 新增订单流水
     *
     * @param addOrderFlowingServiceParam
     * @return
     */
    @Override
    public OrderFlowingDto AddOrderFlowing(AddOrderFlowingServiceParam addOrderFlowingServiceParam) {
        OrderFlowing orderFlowing = new OrderFlowing();
        orderFlowing.setOrderId(addOrderFlowingServiceParam.getOrderId());
        orderFlowing.setFlowingType(addOrderFlowingServiceParam.getFlowingType());
        orderFlowing.setOrderPrice(addOrderFlowingServiceParam.getOrderPrice());
        orderFlowing.setCreateTime(new Date());
        orderFlowing.setAllowanceId(null);
        save(orderFlowing);
        return BeanUtil.copyProperties(orderFlowing, OrderFlowingDto.class);
    }
}
